local zhidao = fk.CreateSkill {

  name = "joy__zhidao",

  tags = { Skill.Compulsory, },

}



zhidao:addEffect(fk.Damage, {
  name = "joy__zhidao",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhidao.name) and player.phase == Player.Play and data.to ~= player and
      not data.to.dead and not data.to:isAllNude() and player:usedSkillTimes(zhidao.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {data.to.id})
    local flag = {"h", "e", "j"}
    local areas = {Player.Hand, Player.Equip, Player.Judge}
    local cards = {}
    for i = 1, 3, 1 do
      if #data.to.player_cards[areas[i]] > 0 then
        table.insert(cards, room:askForCardChosen(player, data.to, flag[i], zhidao.name))
      end
    end
    if #cards > 0 then
      room:obtainCard(player, cards, false, fk.ReasonPrey)
    end
    local mark = type(data.to:getMark("@@joy__zhidao-turn")) == "table" and data.to:getMark("@@joy__zhidao-turn") or {}
    table.insertIfNeed(mark,player.id)
    room:setPlayerMark(data.to,"@@joy__zhidao-turn",mark)
  end,
})

zhidao:addEffect("prohibit", {
  name = "#joy__zhidao_prohibit",
  is_prohibited = function(self, from, to, card)
    return type(to:getMark("@@joy__zhidao-turn")) == "table" and table.contains(to:getMark("@@joy__zhidao-turn"),from.id)
  end,
})

return zhidao